//package com.tjhk.demo.kafka.listener;
//
//import org.apache.kafka.clients.consumer.ConsumerRecord;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.kafka.annotation.KafkaListener;
//import org.springframework.kafka.core.KafkaTemplate;
//import org.springframework.stereotype.Component;
//
//import javax.annotation.Resource;
//import java.util.List;
//
//@Component
//public class FisrtKafkaBatchConsumer {
//
//    private static final Logger log= LoggerFactory.getLogger(FisrtKafkaBatchConsumer.class);
//    @Resource(name = "secondKafkaTemplate")
//    private KafkaTemplate<String, byte[]> firstKafkaTemplate;
//
//
//    /**
//     * 对产品订购消息进行消费处理
//     * @param recordList
//     */
//    @KafkaListener(containerFactory = "firstKafkaListenerContainerFactory"
//            ,topics = "tjg-cyc-location"
//            ,groupId = "tjg-group")
//    public void test(List<ConsumerRecord<String, byte[]>> recordList) {
//
//        log.info(">>>>>>.TreadID:{},接收消息数量：{}条", Thread.currentThread().getId(), recordList.size());
//        for (ConsumerRecord<String, byte[]> record : recordList) {
//            try {
////                log.info("partition={}, offset={}, key ={},value ={}", record.partition(), record.offset(), record.key(), new String(record.value(),"GBK"));
//            } catch (Exception e) {
//                log.error("丢弃消息，数据格式转换错误！-->partition={}, offset={}, key ={},value ={}", record.partition(), record.offset(), record.key(), record.value());
//            }
//        }
//    }
//    /**
//     * 对产品订购消息进行消费处理
//     * @param recordList
//     */
////    @KafkaListener(containerFactory = "firstKafkaListenerContainerFactory"
////            ,topics = "tjg-cyc-location"
////            ,groupId = "tjg-group")
////    public void test(List<ConsumerRecord<String, byte[]>> recordList, Acknowledgment ack) {
////
////        log.info(">>>>>>.TreadID:{},接收消息数量：{}条", Thread.currentThread().getId(), recordList.size());
////        for (ConsumerRecord<String, byte[]> record : recordList) {
////            try {
////                log.info("partition={}, offset={}, key ={},value ={}", record.partition(), record.offset(), record.key(), new String(record.value(),"GBK"));
////            } catch (Exception e) {
////                log.error("丢弃消息，数据格式转换错误！-->partition={}, offset={}, key ={},value ={}", record.partition(), record.offset(), record.key(), record.value());
////            }
////        }
////        ack.acknowledge();
////    }
//
////    /**
////     * 对产品订购消息进行消费处理
////     * @param recordList
////     */
////    @KafkaListener(containerFactory = "firstKafkaListenerContainerFactory"
////            ,topics = "tjg-cyc-location"
////            ,groupId = "tjg-group"
////            , properties = {
////            ConsumerConfig.MAX_POLL_INTERVAL_MS_CONFIG + "=1000"
////            ,ConsumerConfig.MAX_POLL_RECORDS_CONFIG + "=100"
////    })
////    public void test(List<ConsumerRecord<String, byte[]>> recordList) {
////
////        log.info(">>>>>>.TreadID:{},接收消息数量：{}条", Thread.currentThread().getId(), recordList.size());
////        for (ConsumerRecord<String, byte[]> record : recordList) {
////            try {
////                log.info("partition={}, offset={}, key ={},value ={}", record.partition(), record.offset(), record.key(), new String(record.value(),"GBK"));
////            } catch (Exception e) {
////                log.error("丢弃消息，数据格式转换错误！-->partition={}, offset={}, key ={},value ={}", record.partition(), record.offset(), record.key(), record.value());
////            }
////        }
////    }
//
//}
//
